package dao;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import Utiles.*;
import Interface.*;

public class MySqlUsuarioDAO implements UsuarioDAO {

	Connection cn= null;
	CallableStatement cstmt=null;
	List<List<Object>> lis_global = new ArrayList<List<Object>>();
	List<Object> lis_tmp; 
	ResultSet rs=null;
	String sql ="";
	
	@Override
	public List<List<Object>> Agregar() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<List<Object>> Editar() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<List<Object>> Logueo(String id, String Pass) {
		// TODO Auto-generated method stub
		
		cn= MySqlDBConexion.getConexion();
		
		try {		
			sql="{call STP_LOGUEO (?,?)}";
			cstmt = cn.prepareCall (sql);
	         
			cstmt.setString(1,id);
			cstmt.setString(2,Pass);
			
			 rs=cstmt.executeQuery();
			
			while (rs.next()) {
				lis_tmp= new ArrayList<Object>();
				lis_tmp.add(rs.getString(1));
				lis_tmp.add(rs.getString(2));
				lis_tmp.add(rs.getString(3));
				lis_global.add(lis_tmp);
			}
			cn.close();
		} catch (Exception e) {
		e.printStackTrace();
		}
		return lis_global;

	}

}
